package com.example.t1.activity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.widget.TabHost.TabSpec;

import com.example.t1.BaseViewActivity;
import com.example.t1.R;
import com.example.t1.Fragment.Fragment1;
import com.example.t1.Fragment.Fragment2;

/**
 * 
 * 名称：Activity5.java 描述：TabActivity的替代品FragmentTabHost
 * 
 * @author 智迅 zhixun123@gmail.com
 * @date：2013-12-20 上午11:16:20
 */
@SuppressLint("NewApi")
public class Activity5 extends BaseViewActivity {
    private FragmentTabHost mTabHost;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_activity5);
	mTabHost = (FragmentTabHost) findViewById(R.id.tab);
	mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
	TabSpec spec = null;
	spec = mTabHost.newTabSpec("").setIndicator(getTabView());
	mTabHost.addTab(spec, Fragment1.class, null);

	mTabHost.getTabWidget().getChildAt(0)
		.setBackgroundResource(R.drawable.s_tabwight);

	spec = mTabHost.newTabSpec("").setIndicator(getTabView());
	mTabHost.addTab(spec, Fragment2.class, null);

	mTabHost.getTabWidget().getChildAt(1)
		.setBackgroundResource(R.drawable.s_tabwight);
    }

    private View getTabView() {
	return inflater.inflate(R.layout.tab_text, null);
    }

}
